//
//  BrowseThreeTableViewCell.m
//  浏览界面
//
//  Created by lanou on 15/12/17.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "BrowseThreeTableViewCell.h"
#import "BrowseModel.h"
#import "UIImageView+AFNetworking.h"
#import "TaplmageView.h"

@implementation BrowseThreeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.pictureView = [[UIImageView alloc] initWithFrame:(CGRectMake(5, 0, kWidth - 10, kHeight / 2))];
        self.pictureView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.pictureView];
        
        
        
        _priceLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth - 110, 20, 50, 40))];
        _priceLabel.textAlignment = NSTextAlignmentRight;
        _priceLabel.backgroundColor = [UIColor orangeColor];
        _priceLabel.textColor = [UIColor whiteColor];
        _priceLabel.font = [UIFont boldSystemFontOfSize:22];
        [self.pictureView addSubview:_priceLabel];
        _pictureView.userInteractionEnabled = YES;
       
        UILabel *unitLabel = [[UILabel alloc]initWithFrame:(CGRectMake(kWidth - 60, 20, 50, 40))];
        unitLabel.textAlignment = NSTextAlignmentLeft;
        unitLabel.backgroundColor = [UIColor orangeColor];
        unitLabel.font = [UIFont systemFontOfSize:12];
        unitLabel.text = @"元/平米";
        [self.pictureView addSubview:unitLabel];
        
        _nameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(110, kHeight / 2 + 10, kWidth - 220, 35))];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.textColor = [UIColor orangeColor];
        _nameLabel.font = [UIFont boldSystemFontOfSize:20];
        [self addSubview:_nameLabel];
        
        _personalPictureView = [[UIImageView alloc]initWithFrame:(CGRectMake(5, kHeight / 2 + 10, 90, 90))];
        _personalPictureView.layer.masksToBounds = YES;
        _personalPictureView.layer.borderWidth = 2;
        _personalPictureView.layer.cornerRadius = _personalPictureView.bounds.size.height / 2;
        _personalPictureView.layer.borderColor = [[UIColor whiteColor]CGColor];
        [self addSubview:_personalPictureView];
        
        
        
        _addLabel = [[UILabel alloc]initWithFrame:(CGRectMake(110, kHeight / 2 + 45, kWidth - 150, 35))];
        _addLabel.textColor = [UIColor brownColor];
        _addLabel.font = [UIFont systemFontOfSize:18];
        [self addSubview:_addLabel];
        
        self.pictureView.userInteractionEnabled = YES;
        // 给图片添加点击事件
        self.personalPictureView.userInteractionEnabled = YES;
        // 给图片添加点击事件

        
        // 点赞人数
        _numberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(kWidth - 30, kHeight / 2 + 52, 30, 20))];
        _numberLabel.textColor = [UIColor brownColor];
        _numberLabel.font = [UIFont systemFontOfSize:18];
        [self addSubview:_numberLabel];
        
        // 点赞图片
        _likeImageView = [[UIImageView alloc]initWithFrame:(CGRectMake(kWidth - 35, kHeight / 2 + 30, 20, 20))];
        _likeImageView.image = [UIImage imageNamed:@"dianzan.png"];
        _likeImageView.userInteractionEnabled = YES;
        [self addSubview:_likeImageView];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}



// model赋值
- (void)setBrowseModel:(BrowseModel *)browseModel {
    _nameLabel.text = browseModel.title;
    _addLabel.text = browseModel.title_sub;
    _priceLabel.text = browseModel.work_design_price;
    [self.pictureView setImageWithURL:[NSURL URLWithString:browseModel.cover_pic]];
    [self.personalPictureView setImageWithURL:[NSURL URLWithString:browseModel.author_face]];
    _numberLabel.text = browseModel.liked_count;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
